package org.libl.web.servlet.admin;

import org.libl.dao.admin.AdminDao;
import org.libl.dao.admin.impl.AdminDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/xiugai")
public class XiugaiController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

        //String id = request.getParameter("id");
        String username = request.getParameter("username");
        String password = request.getParameter("newpassword");

        AdminDao dao = new AdminDaoImpl();
        int b = dao.edit(username,password);
        System.out.println(b);
        response.setCharacterEncoding("utf-8");
        response.getWriter().write("密码修改成功，将在您退出系统后生效");

//        request.setAttribute("pageBean",pageBean);
//        request.getRequestDispatcher("/student/page.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        doPost(request, response);
    }
}
